namespace Hack.Decompiling.PEA.CLR
{
  using System;
  using System.IO;
  using System.Globalization;
  using System.Collections.Generic;
  using System.Text;

  public class MetadataStreamWriter : BinaryWriter
  {
    #region Constructors
    protected MetadataStreamWriter()
      : base()
    {

    }
    public MetadataStreamWriter(Stream stream)
      : base(stream)
    {

    }
    public MetadataStreamWriter(Stream stream, Encoding encoding)
      : base(stream, encoding)
    {

    }
    #endregion
    #region Methods
    public virtual void WriteBlob(byte[] buffer)
    {
      if (buffer == null) throw new ArgumentNullException("buffer");
      this.Write7BitEncodedInt(buffer.Length);
      base.Write(buffer);
    }
    #endregion
  }

  public class MetadataStreamReader : BinaryReader
  {
    #region Constructors
    public MetadataStreamReader(Stream stream)
      : base(stream)
    {

    }
    public MetadataStreamReader(Stream stream, Encoding encoding)
      : base(stream, encoding)
    {

    }
    #endregion
    #region Methods
    public virtual byte[] ReadBlob()
    {
      return this.ReadBytes(this.Read7BitEncodedInt());
    }
    #endregion
  }

}
